package com.situ.dao.cst_lost;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

@Mapper
public interface LostDao {

    @Insert("insert into cst_lost(lst_cust_name,lst_cust_no,lst_cust_manager_id,lst_cust_manager_name,lst_last_order_date)  \n" +
            "select    c.cust_name  , c.cust_no , c.cust_manager_id ,c.cust_manager_name ,  r.odr_date  \n" +
            "from  cst_customer c \n" +
            "inner join orders r on r.odr_customer=c.cust_name\n" +
            "where datediff(month,r.odr_date,getdate())>6 and not exists (\n" +
            "select * from cst_lost where lst_cust_name=c.cust_name)")
        void dingshi();
}
